<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>渠道政策 管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<form id="insCompChnPol_form">
    <div class="fieldset1 tabel_col tabel_col_1 clearFix">

        <div class="fieldBox col_100">
            <div class="label">保险产品类型</div>
            <div class="field">
                <select name="prdTypCd" id="prdTypCd" data-value="${insCompChnPolVO.prdTypCd}"
                        validate="{required:true,select:true}">
                    <option value=" ">请选择</option>
                    <c:forEach items="${prdTypCdList}" var="item">
                        <option value="${item.code }">${item.codeNm }</option>
                    </c:forEach>
                </select>
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">险种种类</div>
            <div class="field">
                <select name="insTypCd" id="insTypCd" data-value="${insCompChnPolVO.insTypCd}"
                        validate="{required:true,select:true}">
                    <option value=" ">请选择</option>
                    <c:forEach items="${insTypCdList}" var="item">
                        <option value="${item.code }">${item.codeNm }</option>
                    </c:forEach>
                </select>
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <c:if test="${chnCd==1}">
            <div class="fieldBox col_100">
                <div class="label">返利比例</div>
                <div class="field">
                    <input name="rebPct" id="rebPct" type="text" class="ui-textbox" value="${insCompChnPolVO.rebPct}"
                           validate="{required:true,number:true}">
                    <font color="red">(格式：0.21)</font><span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">折扣系数</div>
                <div class="field">
                    <input name="disRat" id="disRat" type="text" class="ui-textbox" value="${insCompChnPolVO.disRat}"
                           validate="{required:false,number:true,maxlength:1}">
                </div>
            </div>
        </c:if>
        <c:if test="${chnCd==2}">
            <div class="fieldBox col_100">
                <div class="label">返利性质</div>
                <div class="field">
                    <select name="rebNatCd" id="rebNatCd" data-value="${insCompChnPolVO.rebNatCd}"
                            validate="{required:true,select:true}">
                        <option value=" ">请选择</option>
                        <c:forEach items="${rebNatCdList}" var="item">
                            <option value="${item.code }">${item.codeNm }</option>
                        </c:forEach>
                    </select>
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">返利金额</div>
                <div class="field">
                    <input name="rebAmt" id="rebAmt" type="text" class="ui-textbox" value="${insCompChnPolVO.rebAmt}"
                           validate="{required:true,number:true}">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">返利时间</div>
                <div class="field">
                    <input name="rebDt" id="rebDt" type="text" class="ui-textbox" value="${insCompChnPolVO.rebDt}"
                           validate="{required:true}">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">项目产品ID</div>
                <div class="field">
                    <input name="prjPrdId" id="prjPrdId" type="text" class="ui-textbox"
                           value="${insCompChnPolVO.prjPrdId}"
                           validate="{required:false,number:true}">
                    <span class="requiredSymbol">*</span><a href="#"><font color="red">选择</font></a>
                </div>
            </div>
        </c:if>
    </div>
    <div class="btnsBox">
        <input type="hidden" id="insCompId" name="insCompId" value="${insCompId}">
        <input type="hidden" id="chnCd" name="chnCd" value="${chnCd}">
        <span id="saveInsCompChnPol_Btn" class="sq-button sq-button-hasicon l-dialog-btn-ok">
        <i class="sqBtnIco_10"></i>保存</span>
        <input type="reset" id="resetBtn" class="l-button l-button-reset Hide">
    </div>
</form>
<script>
    $(function () {
        var insCompChnPolId = "${insCompChnPolVO.id}";//主键ID
        $("#insCompChnPol_form").ligerForm({
            validate: true
        });
        /*保存*/
        $("#saveInsCompChnPol_Btn").click(function (event) {
            var form = liger.get("insCompChnPol_form");
            if (!form.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var data = form.getData();
            $.ligerDialog.hide();
            var _url;
            if (insCompChnPolId == '') {//新增
                _url = '<%=path%>/insurance/insCompChnPol/add.do';
            } else {//修改
                _url = '<%=path%>/insurance/insCompChnPol/modify.do?id=' + insCompChnPolId;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: _url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        $("#resetBtn").click();
                        parent.polGrid.setParm("insCompId", ${insCompId});
                        parent.polGrid.setParm("chnCd", ${chnCd});
                        parent.polGrid.reload();
                        frameElement.dialog.close();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    });
</script>
</body>
</html>
